﻿using System;
using System.Text;
using IAM.Interface.Model.Equals;

namespace IAM.Interface.Common.Abnormity
{
    /// <summary>
    /// 异常消息
    /// </summary>
    public class ResponseException : System.Exception
    {
        #region 构造函数
        /// <summary>
        /// 构造函数
        /// </summary>
        public ResponseException()
        {
            StatusCode = 200;
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="statuscode"></param>
        public ResponseException(int statuscode)
        {
            this.StatusCode = statuscode;
        }
        #endregion
        #region 属性
        private int _statuscode;
        private string _message = "";
        /// <summary>
        /// 操作结果代码
        /// </summary>
        public int StatusCode
        {
            get
            {
                return _statuscode;
            }
            set
            {
                _statuscode = value;
                switch (_statuscode)
                {
                    case 100:
                        this._message = "正在处理。";
                        break;
                    case 200:
                        this._message = "请求的所有数据都处理成功";
                        break;
                    case 206:
                        this._message = "部分数据成功，不影响整体逻辑处理";
                        break;
                    case 400:
                        this._message = "请求格式不符合规范或服务器无法解析";
                        break;
                    case 401:
                        this._message = "该接口需要用户认证，请求消息未通过权限认证";
                        break;
                    case 404:
                        this._message = "需要处理的请求数据不存在";
                        break;
                    case 408:
                        this._message = "请求处理超时";
                        break;
                    case 410:
                        this._message = "某些特定错误，具体错误信息可以在详细的接口参数中体现";
                        break;
                    case 414    :
                        this._message = "请求地址不存在或没有回应";
                        break;
                    case 418:
                        this._message = "不安全的请求";
                        break;
                    case 500:
                        this._message = "服务器遇到了意想不到的情况，无法满足要求";
                        break;
                    case 600:
                        this._message = "员工不存在";
                        break;
                    case 610:
                        this._message = "权限模型错误";
                        break;
                    case 700:
                        this._message = "签名不一致";
                        break;
                    case 710:
                        this._message = "请求超时";
                        break;
                    case 800:
                        this._message = "GUID验证重复";
                        break;
                }
            }
        }
        /// <summary>
        /// 消息
        /// </summary>
        public override string Message
        {
            get
            {
                return _message;
            }
        }
        #endregion
        /// <summary>
        /// 设置状态和信息
        /// </summary>
        /// <param name="statuscode">状态代码</param>
        /// <param name="message">信息</param>
        public void SetStateMessage(int statuscode, string message)
        {
            _statuscode = statuscode;
            _message = message;

        }
    }
}
